package datatypes;

import java.io.Serializable;
import java.util.Comparator;

/**
 * This comparator compares two vertices by only taking the x-coordinate into account.
 * @author andreas
 *
 */
public class VertexXCoordinateComparator implements Comparator<Vertex>, Serializable {
	private static final long serialVersionUID = 1L;

	@Override
	public int compare(Vertex p1, Vertex p2) {
		if (p1.getX() < p2.getX()) return -1;
		if (p1.getX() > p2.getX()) return 1;
		//if x coordinates are equal don't care about the y coordinates and say the two points are equal.
		return 0;
	}

}
